<%@page import="forum.PM"%>
<%@page import="forum.Thread"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Profile</title>

	<style type="text/css">
	div.sub
	{
		width:220px;
		padding:10px;
		border:5px solid gray;
		margin:0px;
	}
	</style>
</head>
<body>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="tmp" scope="page">User Moderator Administrator</c:set>
<c:set var="lvls" scope="page" value="${fn:split(tmp,' ')}"/>
<a href="index.jsp">Back To Index!</a><br><br>

<div style="display: inline-block;float:right;margin-left:auto;margin-right:0px;">
	<table border="1">
		<h3>Profile</h3>
		<tr>
			<th bgcolor="#F0F0F0">Name:</th>		<td>${sessionScope.user.name}</td>
		</tr>
		<tr>
			<th bgcolor="#F0F0F0">Email:</td>		<td>${sessionScope.user.email}</td>
		</tr>
		<tr>
			<th bgcolor="#F0F0F0">ID:</th>		<td> ${sessionScope.user.userID} </td>
		</tr>
		<tr>
			<th bgcolor="#F0F0F0">Level:</th>		<td>${lvls[sessionScope.user.userlvl]}</td>
		</tr>
		<tr>
			<th bgcolor="#F0F0F0">Joined:</th>	<td>${sessionScope.user.joined}</td>
		</tr>
		<tr>
			<th bgcolor="#F0F0F0">#Posts:</th>	<td>${sessionScope.user.numberOfPosts}</td>
		</tr>
	</table>
</div>
	<div>
		<table border="1" style='display: inline-block;'>
		<h2>Your threads</h2>
		<th>Name</th>
		<th>SubForum</th>
		<th>Created On</th>
		<th>Latest Post</th>
		<th>Views</th>
		<th>Replies</th>
			<c:forEach var="thread" items="${sessionScope.threadsByUser}" >
				<tr>
					<td bgcolor="#F0F0F0">
						<a href="thread.jsp?subForumID=${thread.subForumID}&threadID=${thread.threadID}" style="color:#000000;">
							<big>${thread.name}</big><br><small>${thread.creator.name}</small>
						</a>
					</td>
					<td>${thread.subForumName}</td>
					<td bgcolor="E0E0E0">
						<small><nobr>${thread.createdOn }</nobr></small>
					</td>
					<td width = "200px"bgcolor="E0E0E0">
						<small><nobr>${thread.latestPost.createdOn }</nobr><br><nobr>by: ${thread.latestPost.createdBy.name }</nobr></small>
					</td>
					<td width="40px" align="center" bgcolor="#F8F8F8">${thread.replies}</td>
					<td width="40px" align="center" bgcolor="#E0E0E0">${thread.views}</td>
				</tr>
			</c:forEach>
		</table>
	</div>
	
	<br>
	<table border="1">
		<h2>Inbox</h2>
		<th>From</th><th>Message</th>
		<tr>
			<c:forEach var="pm" items="${sessionScope.PMreceive}" >
				<tr>
					<td valign="top" bgcolor="#F0F0F0">${pm.fromEmail}<br><small>${pm.date}</small></td>
					<td width="500px">${pm.message}</td>
				</tr>
			</c:forEach>
		</tr>
	</table>
	<br>
	<table border="1">
		<h2>Outbox</h2>
		<th>To</th><th>Message</th>
		<tr>
			<c:forEach var="pm2" items="${sessionScope.PMsent}" >
				<tr>
					<td valign="top" bgcolor="#F0F0F0">${pm2.toEmail}<br><small>${pm2.date}</small></td>
					<td width="500px">${pm2.message}</td>
				</tr>
			</c:forEach>
		</tr>
	</table>	
</body>
</html>